﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script>
    $(function () {
        gridList();
    })
    function gridList() {
        $('#dg').datagrid({
            url: "/WeixinManage/WxUsers/GetGridJson",
            toolbar: '#toolbar',
            autoRowHeight: false,
            nowrap: true,
            singleSelect: true,
            method: 'get',
            columns: [[
                { field: 'uuId', hidden: true },
                { field: 'Code', title: '模板代码', width: 120, align: 'center' },
                { field: 'TemplateId', title: '模板消息Id', width: 120, align: 'center' },
                { field: 'Title', title: '模板消息标题', width: 120, align: 'center' },
                { field: 'Data_First', title: '内容抬头', width: 120, align: 'center' },
                { field: 'Data_Remark', title: '内容备注', width: 120, align: 'center' },
                 { field: 'LinkUrl', title: '跳转地址Url', width: 120, align: 'center' },
                {
                    field: 'Status', title: '状态', width: 60, align: 'right',
                    formatter: function (value, row, index) {
                        return value == "0" ? "废除" : "可用";
                    }
                },
                { field: 'CreateTime', title: '创建时间', width: 120, align: 'right' }
            ]]
        });

        $("#btn_search").click(function () {
            var queryJson = {
                keyword: $("#txt_keyword").val()
            }
            $('#dg').datagrid('load', queryJson);
        });
    }
    function btn_add() {
        $.modalOpen({
            id: "Form",
            title: "新增模板",
            url: "/WeixinManage/WxTempMsg/Form",
            width: "750px",
            height: "680px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
    function btn_edit() {
        var selected = $('#dg').datagrid('getSelected');
        if (selected != null) {
            $.modalOpen({
                id: "Form",
                title: "修改模板",
                url: "/WeixinManage/WxTempMsg/Form?keyValue=" + selected.uuId,
                width: "750px",
                height: "680px",
                callBack: function (iframeId) {
                    top.frames[iframeId].submitForm();
                }
            });
        }
        else {
            $.modalMsg("未选中数据", "warning");
        }
    }
    function btn_delete() {
        var selected = $('#dg').datagrid('getSelected');
        if (selected != null) {
            $.deleteForm({
                url: "/WeixinManage/WxTempMsg/DeleteForm",
                param: { keyValue: selected.uuId },
                success: function () {
                    $("#dg").datagrid("reload");
                }
            });
        }
        else {
            $.modalMsg("未选中数据", "warning");
        }
    }
    function btn_details() {
        var selected = $('#dg').datagrid('getSelected');
        if (selected != null) {
            $.modalOpen({
                id: "Details",
                title: "查看信息",
                url: "/WeixinManage/WxTempMsg/Details?keyValue=" + selected.uuId,
                width: "750px",
                height: "680px",
                btn: null,
            });
        }
        else {
            $.modalMsg("未选中数据", "warning");
        }
    }
</script>

<div class="gridPanel" style="height:100%;">
    <div id="toolbar" style="padding:2px 5px;">
        <div class="dcui-btn-area">
            <a href="#" id="NF-add" authorize="yes" class="dcui-btn dcui-btn-green" onclick="btn_add()"><i class="fa fa-plus"></i>新建模板</a>
            <a href="#" id="NF-delete" authorize="yes" class="dcui-btn dcui-btn-red" onclick="btn_delete()"><i class="fa fa-trash"></i>删除模板</a>
            <a href="#" id="NF-edit" authorize="yes" class="dcui-btn dcui-btn-blue" onclick="btn_edit()"><i class="fa fa-pencil"></i>修改模板</a>
            <a href="#" id="NF-details" authorize="yes" class="dcui-btn dcui-btn-purple" onclick="btn_details()"><i class="fa fa-eye"></i>查看模板</a>
        </div>
        <script>$('#toolbar').authorizeButton()</script>
        <div class="dcui-search-area">
            关键字: <input class="easyui-textbox" style="width:110px" id="txt_keyword" placeholder="用户名称/手机号码">
            <a href="#" class="easyui-linkbutton" iconCls="icon-search" id="btn_search">查询</a>
        </div>
    </div>

    <table id="dg" class="easyui-datagrid" style="width:100%;min-height:600px;height:100%;"></table>
</div>
